﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sharp.Portal.ExtNet.FormField
{
    /// <summary>
    /// 文件上传字段
    /// </summary>
    public class FileUploadField : ElementField
    {
        /// <summary>
        /// 文件上传字段
        /// </summary>
        /// <param name="fieldName"></param>
        public FileUploadField(string fieldName)
        {
            this.FieldName = fieldName;
        }
        /// <summary>
        /// 生成
        /// </summary>
        /// <param name="nonFirst"></param>
        /// <returns></returns>
        public override string Build(bool nonFirst = false)
        {
            if (this.IsBrowsing() && !this.KeepingXType)
            {
                return $"x.DisplayFieldFor(m => m.{this.FieldName})" + base.Build(nonFirst);
            }

            return $"x.FileUploadField(m => m.{this.FieldName})" + base.Build(nonFirst);
        }
    }
}